package com.qf.controller;

import com.qf.pojo.req.UserAssessReq;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.UserAssessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserAssessController
 * @Description TODO
 * @Author 16222
 * @Date 2022/9/29 14:18
 * @Version 1.0
 **/
@RestController
@RequestMapping("userAssess")
@Api(tags = "评论")
public class UserAssessController {
    @Autowired
    UserAssessService userAssessService;
    @PostMapping("findAllByStoreIdAndGoodsId")
    @ApiOperation(value = "按商店、商品查找固定菜的评价，需要传入商店id，食品id")
    public BaseResp findAllByStoreIdAndGoodsId(@RequestParam("storeId") int storeId,@RequestParam("goodsId") int goodsId) {
        BaseResp allByStoreIdAndGoodsId = userAssessService.findAllByStoreIdAndGoodsId(storeId, goodsId);
        return allByStoreIdAndGoodsId;
    }
    @PostMapping("findAllByStoreIdAndUserId")
    @ApiOperation(value = "按商店查找固定菜的评价，需要传入商店id")
    public BaseResp findAllByStoreIdAndUserId(@RequestParam("storeId") int storeId) {
        BaseResp allByStoreId = userAssessService.findAllByStoreId(storeId);
        return allByStoreId;
    }
    @PostMapping("findAllByUserId")
    @ApiOperation(value = "按用户查找的评价，需要传入用户id")
    public BaseResp findAllByUserId(@RequestParam("userId") int userId) {
        BaseResp allByUserId = userAssessService.findAllByUserId(userId);
        return allByUserId;
    }
    @PostMapping("saveAndFlush")
    @ApiOperation(value = "储存评价，需要传入（评价信息：）assessMessage （用户ID：）userId（商店ID：） storeId（食品ID：） goodsId")
    public BaseResp saveAndFlush(@RequestBody  UserAssessReq userAssessReq){
        BaseResp baseResp = userAssessService.saveAndFlush(userAssessReq);
        return baseResp;
    }
}
